// Author: Ivan Kazmenko (gassa@mail.ru)
module solution;
import std.algorithm;
import std.math;
import std.stdio;

struct Point
{
	int x;
	int y;
}

int vp () (const auto ref Point a,
    const auto ref Point b, const auto ref Point c)
{
	return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
}

int dist2 () (const auto ref Point a, const auto ref Point b)
{
	return (a.x - b.x) ^^ 2 + (a.y - b.y) ^^ 2;
}

void main ()
{
	int tests;
	readf (" %s", &tests);
	foreach (test; 0..tests)
	{
		Point a, b, c, p, q;
		readf (" %s %s", &a.x, &a.y);
		readf (" %s %s", &b.x, &b.y);
		readf (" %s %s", &c.x, &c.y);
		readf (" %s %s", &p.x, &p.y);
		readf (" %s %s", &q.x, &q.y);
		long area2 = vp (a, b, c) ^^ 2;
		long base2 = max (dist2 (a, b), dist2 (b, c), dist2 (c, a));
		long gate2 = dist2 (p, q);
		writeln ((area2 <= gate2 * base2) ? "YES" : "NO");
	}
}
